/*
ID:luongho3
LANG:JAVA
TASK:milk4
 */
import java.io.File;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;


public class milk4 {

	int Q, P, min;
	int[] pails = new int[150];
	Stack<Integer> best, curr;
	
	public static void main(String[] args) throws Exception {
		milk4 prob = new milk4();
		prob.read();
		prob.solve();
	}

	public void read() throws Exception {
		Scanner scanner = new Scanner(new File("milk4.in"));
		Q = scanner.nextInt();
		P = scanner.nextInt();
		for (int i=1;i<=P;++i) {
			pails[i] = scanner.nextInt();
			for (int j=i-1;j>=1;--j) {
				if (pails[i] % pails[j] == 0) {
					i--;
					P--;
					break;
				}
				else if (pails[j] % pails[i] == 0) {
					pails[j] = pails[i];
					i--;
					P--;
					break;
				}
			}
		}
	}
	
	public void solve() throws Exception {
		PrintStream ps = new PrintStream(new File("milk4.out"));
		Arrays.sort(pails,1,P+1);
		System.setOut(ps);
		
//		System.out.println(P);
//		for (int i=1;i<=P;++i) {
//			System.out.print(pails[i] + " ");
//		}
//		System.out.println();
		
		ps.close();
	}
	
}
